<template>
<div class="content">

<!--<div class="text main-text">欢迎使用四六级在线课程平台</div>-->
  <div class="dashboard-editor-container" >

    <panel-group @handleSetLineChartData="handleSetLineChartData"
                 :inventory="inventory[0] === '暂无数据' ? 0 :inventory.length"
                 :repair-time="repairTime[0] === '暂无数据' ? 0 : repairTime.length"/>

    <el-row style="background:#fff;padding:16px 16px 0;margin-bottom:32px;">

      <div style="width: 100%;padding-bottom: 10px;margin-top: -10px;">
        <line-chart :chart-data="lineChartData"/>
      </div>
    </el-row>

  </div>
</div>
</template>
<script>
import PanelGroup from './dashboard/PanelGroup'
import LineChart from './dashboard/LineChart'
import router from '@/router/router-static'
const lineChartData = {
  newVisitis: {
    inputData: [],
    outputData: [],
    lendData: []
  }
}
export default {
  components: {
    PanelGroup,
    LineChart,
  },
  mounted(){
    this.init();
  },
  data() {
    return {
      repairTime: [],
      inventory: [],
      lineChartData: lineChartData.newVisitis,
    }
  },
  methods:{
    handleSetLineChartData(type) {
      this.lineChartData = lineChartData[type]
    },
    init(){
      lineChartData.newVisitis.inputData = [12, 32, 45, 15,42, 50, 15]
      lineChartData.newVisitis.outputData = [25, 30, 45, 10, 15, 14, 30]
      lineChartData.newVisitis.lendData = [80, 89, 98, 106, 125, 100, 130]
        if(this.$storage.get('Token')){
        this.$http({
            url: `${this.$storage.get('sessionTable')}/session`,
            method: "get"
        }).then(({ data }) => {
            if (data && data.code != 0) {
            router.push({ name: 'login' })
            }
        });
        }else{
            router.push({ name: 'login' })
        }
    }
  }
};
</script>

<style lang="scss" scoped>
.content {
  display: flex;
  align-items: center;
  flex-direction: column;
  width: 100%;
  height: 100%;
  min-height: 500px;
  text-align: center;
  .main-text{
    font-size: 38px;
    font-weight: bold;
    margin-top: 15%;
  }
  .text {
    font-size: 24px;
    font-weight: bold;
    color: #333;
  }
}
.dashboard-editor-container {
  padding: 32px;
  background-color: rgb(240, 242, 245);
  position: relative;

  .chart-wrapper {
    background: #fff;
    padding: 16px 16px 0;
    margin-bottom: 32px;
  }
}
</style>
